searchin different attributes between different modules

Hi, I'm very new to DOORS and am struggling a bit with a problem.

I need to count the number of derived requirements in three different modules and create metrics to compare them. Unfortunatley the modules contain different attributes for the same information, namely "Source" in two modules and "Source of Requirments" in the other, with the former containing free text and the later enumerations. We have a tool to help produce the code to get the metrics but it's falling down big style with this.

The codeproduced is this;

Object o
Link lnk
int count = 0
bool b = true
bool c
string boolOrder = "(1) || (2) || (3)"
string boolStr = ""
string testval = "false"
Skip boolVals = create
Regexp rpl = regexp("^0-9(0-9+)^0-9")
for o in m do
{
boolStr = boolOrder
b = (o."Source""" == "Derived")
put(boolVals,1,b)
boolStr = boolOrder
b = (o."Source""" == "Derived Requirement")
put(boolVals,2,b)
boolStr = boolOrder
b = (o."Source of Requirement""" == "Derived Requirement")
put(boolVals,3,b)
while(rpl boolStr)
{
if(find(boolVals,intOf boolStrmatch 1"",c))
boolStr = boolStr0:start 1-1 c boolStrend 1+1:""
else
boolStr = boolStr0:start 1-1 "false" boolStrend 1+1:""
}

testval = eval_ "return_ ("boolStr")\"\""

if(testval == "true")
b = true
else
b = false

delete boolVals
boolVals = create

if(b)
count++
}
delete boolVals
return_ count""

If I run this I get 0 for everything, if I remove the code for the 2 "Source" counts or the "Source of Requirement" count it works fine. Any suggestions would be most appreciated.

{BTW in the future we will ensure the modules are created to a standard, but I cannot access them to change the attributes so would like to get the codeworking :-)}
CalumB - Mon Feb 27 04:32:11 EST 2012

Re: searchin different attributes between different modules
llandale - Mon Feb 27 18:46:34 EST 2012

Yes, surround your code with {code} statements, and preview before posting.

I think your code is trying to turn this:

  • "(1) || (2) || (3)"

into something like this:

  • "(false) || (true) || (false)"

and if there are any "true" statements then this object qualifies and count++.

--snip what I'm thinking about that--

The code should be failing with DXL errors in any module that lacks both attributes "Source" and "Source of Requirement"; as [o."Source"] will fail if it doesn't exist. Instead, use the worst kept secret in DXL and use this built-in function to get attr values:

  • Value = probeAttr_(o, NameOfAttr)

That does attribute existence checking and some other nice checks, and you gracefully get a null string if it doesn't exist.

In any event, perhaps you want something like this:

count = 0
for o in mod do
{  if ( probeAttr_(o, "Source") == "Derived"    or
       probeAttr_(o, "Source") == "Derived Requirement"    or
       probeAttr_(o, "Source of Requirement") == "Derived Requirement") //
   then count++
}


-Louie

Yes, that block was surrounded with {code} and looks rather nice.

Re: searchin different attributes between different modules
CalumB - Thu Mar 01 03:27:18 EST 2012

Thanks. I'll sort out my previewing/posting of code next time as well :-)